﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Teacker_kit_Blank_App.ViewModels.Commands;
using Windows.UI.Popups;
using Teacker_kit_Blank_App.DataModel;

namespace Teacker_kit_Blank_App.ViewModels
{
    class StudentViewModel : ViewModelBase
    {

        public StudentViewModel()
        {
            StudentName = "Mostafa";
            //LstStudent = new Student().GetAll();
        }

        #region Properties

        private string _StudentName;
        public string StudentName
        {
            get { return _StudentName; }
            set
            {
                _StudentName = value;
                OnPropertyChanged("StudentName");
                //if (_SendEmailCommand != null)
                //{
                //    ((DelegateCommand)_SendEmailCommand).RaiseCanExecuteChanged();
                //}
            }
        }


        private ObservableCollection<Student> _LstStudent;
        public ObservableCollection<Student> LstStudent
        {
            get { return _LstStudent; }
            set
            { 
                _LstStudent = value;
                OnPropertyChanged("LstStudent");
            }
        }

        private Student _SelectedStudent;
        public Student SelectedStudent
        {
            get { return _SelectedStudent; }
            set 
            {
                _SelectedStudent = value;
                OnPropertyChanged("SelectedStudent");
            }
        }

        #endregion

        #region Commands

        #region Add

        ICommand _Add;
        public ICommand Add
        {
            get
            {
                _Add = new DelegateCommand(AddStudent, CanAddStudent);
                return _Add;
            }
        }

        private async void AddStudent(object parameter)
        {
            MessageDialog messageDialog = new MessageDialog("Welcome to Windows 8 Store Apps", StudentName);
            await messageDialog.ShowAsync();
        }

        private bool CanAddStudent(object parameter)
        {
            return PageIsValid();
        }
        #endregion

        #region Edit

        ICommand _Edit;
        public ICommand Edit
        {
            get
            {
                _Edit = new DelegateCommand(EditStudent, CanEditStudent);
                return _Edit;
            }
        }

        private async void EditStudent(object parameter)
        {
            MessageDialog messageDialog = new MessageDialog("Welcome to Windows 8 Store Apps", StudentName);
            await messageDialog.ShowAsync();
        }

        private bool CanEditStudent(object parameter)
        {
            return PageIsValid();
        }
        #endregion

        #endregion

        bool PageIsValid()
        {
          
            //bool x = EttamenUserValidation.EmailValidation(Email);
            bool x = true;
            return x;
        }



    }
}
